package OSMS.action.Boss;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import OSMS.entity.*;
import OSMS.dao.*;

public class OrderSearchServlet extends HttpServlet {

	private GoodsDao dao = new GoodsDao();
	
	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		request.setCharacterEncoding("utf-8");
		//从session中获取当前登录商家的bid 所以只能查找该商家旗下所有商品的订单
		HttpSession session = request.getSession();
		Object obj_user = session.getAttribute("boss");
		Boss boss = (Boss) obj_user;
		String bid = null;
		Object id1 = boss.getBid();
		bid = id1.toString();	
		//获取goodslist.jsp传来的gid
		Object id2 = request.getParameter("gid");
		String gid = null;
		if(id2!=null){
			gid=id2.toString();
		}

		boolean flag = false ;
		try {
			//调用dao的方法查询商品数据
			List<Order> GoodsOrderList = dao.getGoodsorderByGid(bid,gid);
			//将数据装入域对象中
			request.setAttribute("GoodsOrderList", GoodsOrderList);
			//将查询结果跳转到seartchgoods.jsp页面中展示
			request.setCharacterEncoding("utf-8");
			request.getRequestDispatcher("searchorder.jsp").forward(request, response);
		}catch(Exception e) {
			e.printStackTrace();
		}
		
	}

	@Override
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		this.doGet(request, response);
	}
	
	
}
